<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="asserts/css/dashboard.css" th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
		<style type="text/css">
			/* Chart.js */

			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}

			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}

			.chartjs-render-monitor {
				-webkit-animation: chartjs-render-animation 0.001s;
				animation: chartjs-render-animation 0.001s;
			}
		</style>
	</head>

	<body>
		<!--引入抽取的顶部工具栏-->
		<!--模版名::片段名称-->
		<!--main:就是thymeleaf的解析页面就是main.html-->
		<!--注意:这里会把nav:包含在一个div里面,这不是我们想要的-->
		<!--th:insert：将公共片段整个插入到声明引入的元素中-->
		<!--th:replace：将声明引入的元素替换为公共片段-->
		<!--th:include：将被引入的片段的内容包含进这个标签中-->
		<!--所以使用replace-->
		<!--直接这么写main::topbar也是支持的-->
		<div th:replace="commons/bar::topbar"></div>

		<div class="container-fluid">
			<div class="row">

				<div th:replace="commons/bar::sidebar(active='emps')"></div>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<h2>员工列表</h2>
					<a class="btn btn-sm btn-primary" th:href="@{/emp}">添加</a>
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
								<tr>
									<th>#</th>
									<th>userName</th>
									<th>email</th>
									<th>gender</th>
									<th>department</th>
									<th>birth</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<!--循环的写法-->
								<tr th:each="emp :${emps}">
									<td th:text="${emp.id}">1,001</td>
									<td th:text="${emp.userName}">Lorem</td>
									<td th:text="${emp.email}">ipsum</td>
									<!--三元运算符-->
									<td th:text="${emp.gender}==0?'男':'女'">dolor</td>
									<td th:text="${emp.department.departmentName}">sit</td>
									<!--格式化-->
									<td th:text="${#dates.format(emp.birth,'yyyy-MM-dd')}">sit</td>
									<td >
										<a class="btn btn-sm btn-primary" th:href="@{/emp/}+${emp.id}" >编辑</a>
										<a class="btn btn-sm btn-danger deletebtn" th:attr="del_uri=@{/emp/}+${emp.id}" >删除</a>
									</td>
								</tr>

							</tbody>
						</table>
					</div>
				</main>
                <form id="deleteform" th:action="@{/emp/}+@{emp.id}" method="post">
                    <input type="hidden" name="_method" value="delete">
                </form>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js" th:src="@{/webjars/jquery/3.3.1/jquery.js}"></script>
		<script type="text/javascript" src="asserts/js/popper.min.js" th:src="@{asserts/js/popper.min.js}"></script>
		<script type="text/javascript" src="asserts/js/bootstrap.min.js" th:src="@{/asserts/js/bootstrap.min.js}"></script>

		<!-- Icons -->
		<script type="text/javascript" src="asserts/js/feather.min.js" th:src="@{/asserts/js/feather.min.js}"></script>
		<script>
			feather.replace()
		</script>

		<!-- Graphs -->
		<script type="text/javascript" src="asserts/js/Chart.min.js" th:src="@{/asserts/js/Chart.min.js}"></script>
		<script>
			$(".deletebtn").click(function () {
			    var del_uri = $(this).attr("del_uri");
                $("#deleteform").attr("action",del_uri).submit();
				return false;
            });
		</script>

	</body>

</html>